package br.com.fa7.service;

import br.com.fa7.entity.Fight;
import br.com.fa7.util.LOG;

public class ManagementFight extends Thread {
	private String game;
	private Fight fight;
	private boolean hasNewEvent;
	
	public ManagementFight() {
		LOG.log("Criando nova luta");
		
		createNewFight();
	}
	
	public void createNewFight(){
		fight = new Fight();
	}
	
	public boolean hasNewEvent(){
		if(hasNewEvent){
			hasNewEvent = false;
			
			return true;
		}
		
		return false;
	}
	
	public String getCurrentFightStatus(){
		if(fight.getWinner() == null){
			game = fight.attack();
		}else{
			game = "";
		}
		
		return game;
	}

	@Override
	public void run() {
//		long currentTime = new Date().getTime();
//		long twoMinutesAfter = currentTime + 120000;
		
		while(true) {
			LOG.log("criando evento");
			hasNewEvent = true;
			try {
                Thread.sleep((int)(Math.random() * 10000));
            } catch (InterruptedException e) { }
            
//            currentTime = new  Date().getTime();
        }
	}
	
}
